<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="msg"></div>
  <input id="inp" type="text">
  <script>
    let msg='你好DOM'
    document.getElementById('inp').value=msg;
    document.getElementById('inp').oninput=evt=>{
      msg=evt.target.value;
      document.getElementById('msg').innerHTML=msg;
    }
    document.getElementById('msg').innerHTML=msg;
  </script>
</body>
</html>